package com.tuojiahr.init;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.tuojiahr.global.Constants;

/**
 * 说明：
 *
 * @author wang.haibo
 * @date 2012-11-11 下午4:45:38
 */

public class InitConfig {

	/**
	 * 初始化日志
	 * @throws IOException
	 */
	public void initLog() throws IOException {
		Properties props = new Properties();
		InputStream in = InitConfig.class.getClassLoader().getResourceAsStream("log4j.properties");
		try {
			props.load(in);
			String logPath =props.getProperty("log4j.path").trim();
			File logFolder=new File(logPath);
			if(!logFolder.exists()){
				logFolder.mkdirs();
			}
			PropertyConfigurator.configure(props);
			Constants.ExceptionLog = Logger.getLogger("ExceptionLog");
		} catch (IOException e) {
			throw e;
		} finally {
			in.close();
			in = null;
		}
	}
}
